package com.wang.thread;

import com.wang.util.RollingWindow;
import org.joda.time.DateTime;

/**
 * 滚动窗口
 * Created by wang on 2017/5/4.
 */
public class RollingWindowTimer implements Runnable {
    //注入
    private int[] count;

    public RollingWindowTimer(int[] count) {
        this.count = count;
    }

    @Override
    public void run() {
        while (true) {
            try {
                //设置分时间隔  6秒
                Thread.sleep(6000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("最近一分钟访问了："+ RollingWindow.getRequestTimes()+"次，即将刷新。");
            System.arraycopy(count, 1, count, 0, count.length - 1);
            count[5] = 0;
        }
    }
}
